# delimit ;
clear ;
cd "replication" ;
set more off ; 

* *************************************************************************** ;
* re-run midline analysis
* *************************************************************************** ;

cd ".." ;
do "./replication/do/table03-midline-knowledge-aggregate.do" ; 

****************************************************************************** ;
* robustness check: drop wave 1 respondents from the analysis
****************************************************************************** ;

drop if wave == 1 ;
est drop _all ; 

* regressions: agggregate scores ; 
foreach var of varlist score* { ; 

	areg `var' healthonly healthandpay, a(strata) robust ;
	qui est sto `var'; 
	
	test healthonly = healthandpay ; 
	estadd local titlerow = "" ; 
	estadd scalar fstat = r(F): `var' ; 
	estadd scalar pval = r(p): `var' ; 

	summarize `var' if control == 1 & e(sample) == 1;
	estadd scalar cmean = r(mean): `var' ; 
	estadd scalar csd = r(sd): `var' ;

} ;

esttab score* using "./output/appendix-table-midline-knowledge-aggregate-excluding-wave1.tex",
	replace
	drop(_cons) 
	cells(b(label() star fmt(%9.3f %9.3f)) se(par)) 
	star(* 0.10 ** 0.05 *** 0.01) 
	stats(titlerow fstat pval cmean csd N, fmt(%9s %9.3f %9.3f %9.3f %9.3f %9.0f) labels("\(F\)-test, HEE = HEEC" "$\qquad$ \(F\)-statistic" "$\qquad$ \(p\)-value" "Control Mean" "Control SD" "N"))
prehead(\begin{table}[htbp] \centering \normalsize `"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"'
		\captionsetup{justification=centering} 
		\caption{Effects on Short-Term Health Knowledge \\ Excluding Wave 1 Respondents}
		\label{table-midline-knowledge-aggregate-excluding-wave1}
		\begin{tabular*}{0.78\hsize}{p{3.7cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}}
		\toprule)
	legend label  booktabs  collabels( , none)
	mgroups(
	"All Topics" 
	"By Topic" 
	, pattern(1 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
	postfoot(`"\bottomrule"'  \end{tabular*} \captionsetup{justification=justified, width=0.78\hsize} 
		\caption*{\footnotesize \textit{Notes:} Re-estimation of Table \ref{table-midline-knowledge-aggregate},
		but excluding Wave 1 respondents in the regression sample.
		***\$\,p < 0.01$, **\$\,p < 0.05$, *\$\,p<0.10$.
		}
		\end{table}) ;

exit ;
